# !/user/bin/env python3
# -*- encoding: utf-8 -*-

"""
  json文件转xlsx文件
"""

import json
import tablib

rows = []
with open("data.json", "r") as f:
    jsonData = json.load(f)
    rows = jsonData["List"]

header = tuple([i for i in rows[0].keys()])

data = []
for row in rows:
    rowData = []
    for value in row.values():
        rowData.append(value)
    data.append(rowData)

tData = tablib.Dataset(*data, headers=header)
open("data.xlsx", "wb").write(tData.xlsx)
